import VueRouter from "vue-router";

// 引入组件
import Home from "../pages/home.vue"
// import Login from "../pages/login.vue"


let router = new VueRouter({
  routes:[
    {
      path:"/",
      redirect:"/home"
    },
    {
      path:"/home",
      component:Home,
      children:[
        
      ]
    },
    {
      path:"/login",
      component: () => import("../pages/login.vue"),
      beforeEnter(to,from,next){
        // console.log(to);
        // console.log(from);

        if(to.query.top_nav){
          next()
        }else{
          next("/home")
        }
      }
    },
    {
      path:"/commodity",
      component: () => import("../pages/commodityItem.vue"),
      beforeEnter(to,from,next){
        // console.log(to);
        // console.log(from);

        if(to.query.commodityItemId){
          next()
        }else{
          next("/home")
        }
      }
    },
    {
      path:"/shopping",
      component: () => import("../pages/shopping.vue"),
      // beforeEnter(to,from,next){
      //   // console.log(to);
      //   // console.log(from);

      //   if(to.query.commodityItemId){
      //     next()
      //   }else{
      //     next("/home")
      //   }
      // }
    }
     
  ]
})

export default router